From c3f630376436d3451384afef0cbcf8fe789e1e8d Mon Sep 17 00:00:00 2001 From: robertlipe Date: Mon, 9 Jun 2014 17:39:07 +0000 Subject: [PATCH] Fixes for subrip. --- .../track/gpx_subsecond-sample~subrip.srt | 15 ++++--- gpsbabel/subrip.cc | 45 ++++++------------- 2 files changed, 24 insertions(+), 36 deletions(-) diff --git a/gpsbabel/reference/track/gpx_subsecond-sample~subrip.srt b/gpsbabel/reference/track/gpx_subsecond-sample~subrip.srt index 2d69cc6ff..00803a8ab 100644 --- a/gpsbabel/reference/track/gpx_subsecond-sample~subrip.srt +++ b/gpsbabel/reference/track/gpx_subsecond-sample~subrip.srt @@ -1,20 +1,25 @@ 1 -17:47:25,200 --> 17:47:25,400 --> 49.7 km/h 289 m +00:00:00,200 --> 00:00:00,400 +49.7 km/h 289 m 17:47:25 Lat=49.79469 Lon=9.83402 2 -17:47:25,400 --> 17:47:25,600 --> 50.6 km/h 289 m +00:00:00,400 --> 00:00:00,600 +50.6 km/h 289 m 17:47:25 Lat=49.79472 Lon=9.83400 3 -17:47:25,600 --> 17:47:25,800 --> 51.0 km/h 289 m +00:00:00,600 --> 00:00:00,800 +51.0 km/h 289 m 17:47:25 Lat=49.79474 Lon=9.83398 4 -17:47:25,800 --> 17:47:26,000 --> 50.7 km/h 289 m +00:00:00,800 --> 00:00:01,000 +50.7 km/h 289 m 17:47:25 Lat=49.79476 Lon=9.83396 5 -17:47:26,000 --> 17:47:27,000 --> 51.1 km/h 289 m +00:00:01,000 --> 00:00:02,000 +51.1 km/h 289 m 17:47:26 Lat=49.79479 Lon=9.83394 diff --git a/gpsbabel/subrip.cc b/gpsbabel/subrip.cc index 2bf1b0862..c42d0891d 100644 --- a/gpsbabel/subrip.cc +++ b/gpsbabel/subrip.cc @@ -53,32 +53,12 @@ sync_time(time_t arg_gpstime, char* arg_videotime) return result; } -static QDateTime -gps_to_video_time(QDateTime arg_gpstime) -{ - QDateTime result = arg_gpstime; - /* Converts a GPS timestamp to relative time in the video stream. */ - result.addSecs(time_offset); - return result; -} - -// This appears to be only for subtitles so it's OK if we "wrap" -// times across a midnight boundary. -static void -subrip_write_duration(QDateTime startdtime, QDateTime enddtime) -{ - QTime starttime = startdtime.time(); - QTime endtime = enddtime.time(); - - /* Writes start and end time for subtitle display to file. */ - gbfprintf(fout, "%02d:%02d:%02d,%03d --> ", starttime.hour(), starttime.minute(), starttime.second(), starttime.msec()); - - gbfprintf(fout, "%02d:%02d:%02d,%03d --> ", endtime.hour(), endtime.minute(), endtime.second(), endtime.msec()); -} - static void subrip_prevwp_pr(const Waypoint* waypointp) { + QDateTime startdtime, enddtime; + QTime starttime, endtime; + /* Now that we have the next waypoint, we can write out the subtitle for * the previous one. */ @@ -90,17 +70,20 @@ subrip_prevwp_pr(const Waypoint* waypointp) return; } - QDateTime starttime = gps_to_video_time(prevwpp->GetCreationTime()); - QDateTime endtime; + gbfprintf(fout, "%d\n", stnum++); + /* Writes start and end time for subtitle display to file. */ + startdtime = prevwpp->GetCreationTime().addSecs(-time_offset); if (!waypointp) { - endtime = starttime.addSecs(1); + enddtime = startdtime.addSecs(1); } else { - endtime = gps_to_video_time(waypointp->GetCreationTime()); + enddtime = waypointp->GetCreationTime().addSecs(-time_offset); } - gbfprintf(fout, "%d\n", stnum); - stnum++; - subrip_write_duration(starttime, endtime); + starttime = startdtime.toUTC().time(); + endtime = enddtime.toUTC().time(); + gbfprintf(fout, "%02d:%02d:%02d,%03d --> %02d:%02d:%02d,%03d\n", + starttime.hour(), starttime.minute(), starttime.second(), starttime.msec(), + endtime.hour(), endtime.minute(), endtime.second(), endtime.msec()); for (char* c = opt_format; *c != '\0' ; c++) { char fmt; @@ -125,7 +108,7 @@ subrip_prevwp_pr(const Waypoint* waypointp) break; case 't': { - QTime t = prevwpp->GetCreationTime().time(); + QTime t = prevwpp->GetCreationTime().toUTC().time(); gbfprintf(fout, "%02d:%02d:%02d", t.hour(), t.minute(), t.second()); break; } -- 2.30.2